package com.indusfo.spc.client.controller;

import com.indusfo.spc.annotation.UserLoginToken;
import com.indusfo.spc.client.pojo.ClientOrderChange;
import com.indusfo.spc.client.service.ClientOrderChangeService;
import com.indusfo.spc.vo.JSONObject;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 客户端型号变更控制层
 * 
 * @author zhengd
 * @create 2019-12-12
 */
@RestController
@RequestMapping("/client/orderChange")
public class ClientOrderChangeController {

	@Autowired
	private ClientOrderChangeService clientOrderChangeService;

	/**
	 * 保存型号变更
	 * 
	 * @param ClientOrderChange
	 * @return
	 */
	@PostMapping("/saveClientOrderChange")
	@UserLoginToken
	public JSONObject saveClientOrderChange(@RequestBody ClientOrderChange clientOrderChange) {
		try {
			return JSONObject.oK(clientOrderChangeService.saveClientOrderChange(clientOrderChange));
		} catch (Exception e) {
			return JSONObject.build(JSONObject.ERROR, e.getMessage());
		}
	}

	/**
	 * 根据批号查询基本信息
	 * 
	 * @param batchCode
	 * @return
	 */
	@PostMapping("/selectClientOrderChangeByBatchCode")
	@UserLoginToken
	public JSONObject selectClientOrderChangeByBatchCode(@RequestBody Map<String, String> map) {
		try {
			return JSONObject.oK(clientOrderChangeService.selectClientOrderChangeByBatchCode(map.get("batchCode")));
		} catch (Exception e) {
			return JSONObject.build(JSONObject.ERROR, "系统异常");
		}
	}

}
